from Window import Window
from EventHandler import EventHandler
from Pathfinding import Pathfinding
from Person import Person
from Box import Box
from Game import Game
from Level import Level
import pygame
import UAI
import Debug

DEBUG = True   

def Init(datadir):
    pygame.mouse.set_visible(1)
    UAI.screen = pygame.display.set_mode((UAI.options.width, UAI.options.height), UAI.options.fullscreen)
    UAI.clock  = pygame.time.Clock()
    UAI.font10 = pygame.font.Font(datadir + "/fonts/alien.ttf", 10)
    UAI.font16 = pygame.font.Font(datadir + "/fonts/alien.ttf", 16)
    UAI.window = Window()
    UAI.event  = EventHandler()
    UAI.game   = Game()
    UAI.pathfinding = Pathfinding()
    
    pygame.display.set_caption("UAI")

def Loop():
    while not UAI.QUIT:
        UAI.clock.tick(60)
        UAI.event.handleEvents()
        if not UAI.PAUSE:
            UAI.game.run()
            UAI.window.draw()
            UAI.game.draw()
        pygame.display.flip()
    pygame.time.delay(3000)

if __name__ == '__main__':
    UAI.DEBUG = True
    pygame.init()
    Init('data')

    UAI.game.level = Level('test')
    UAI.game.level.load()
    
    UAI.pathfinding.preMapGeneration()
    Loop()